package jude.java.money.service;

import jude.java.money.beans.global.BaseBean;
import jude.java.money.spring.Services;

import org.hibernate.HibernateException;
import org.hibernate.TransactionException;
import org.springframework.dao.DataAccessException;

public class DB {

	/**
	 * no transaction insert
	 * @return is successful
	 * */
	public static <T extends BaseBean> boolean ntInsert(T o) {
		try {
			Services.getGlobalService().insert(o);
			return true;
		} catch (DataAccessException e) {
		} catch (TransactionException e) {
		} catch (HibernateException e) {
//		} catch (AssertionFailure e) {
//		} catch (Throwable e) {
//			e.printStackTrace();
		}
		return false;
	}

	/**
	 * no transaction update
	 * @return is successful
	 * */
	public <T extends BaseBean> boolean ntUpdate(T o) {
		try {
			Services.getGlobalService().update(o);
			return true;
		} catch (DataAccessException e) {
		} catch (TransactionException e) {
		} catch (HibernateException e) {
		}
		return false;
	}
}
